//
//  BrandDescTableViewCell.m
//  UGoods
//
//  Created by dllo on 16/1/21.
//  Copyright © 2016年 蓝鸥科技.李贺. All rights reserved.
//

#import "BrandDescTableViewCell.h"
#import "BaseView.h"
#import "ConstantsDefine.h"
@interface BrandDescTableViewCell ()

@property (nonatomic, retain) UIImageView *siteImageView;
@property (nonatomic, retain) UIView *lineView;
@property (nonatomic, retain) BaseView *backView;

@end

@implementation BrandDescTableViewCell

- (void)dealloc
{
    [_logoImageView release];
    [_brandLabel release];
    [_siteLabel release];
    [_descLabel release];
    [_siteImageView release];
    [_lineView release];
    [_backView release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backView = [[BaseView alloc] init];
        [self.contentView addSubview:_backView];
        [_backView release];
        
        self.logoImageView = [[UIImageView alloc] init];
        _logoImageView.layer.cornerRadius = 20;
        _logoImageView.layer.borderWidth = 0.5;
        _logoImageView.layer.borderColor = [UIColor blackColor].CGColor;
        _logoImageView.layer.masksToBounds = YES;
        [self.backView addSubview:_logoImageView];
        [_logoImageView release];
        
        self.brandLabel = [[BaseLabel alloc] init];
        self.brandLabel.textAlignment = NSTextAlignmentLeft;
        [self.backView addSubview:_brandLabel];
        [_brandLabel release];
        
        self.siteImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"iconfont-svg18-2"]];
        [self.backView addSubview:_siteImageView];
        [_siteImageView release];
        
        self.siteLabel = [[BaseLabel alloc] init];
        self.siteLabel.textAlignment = NSTextAlignmentLeft;
        _siteLabel.textColor = [UIColor grayColor];
        _siteLabel.font = [UIFont systemFontOfSize:13 * WIDTH];
        [self.backView addSubview:_siteLabel];
        [_siteLabel release];
        
        self.lineView = [[UIView alloc] init];
        _lineView.backgroundColor = [UIColor grayColor];
        [self.backView addSubview:_lineView];
        [_lineView release];
        
        self.descLabel = [[BaseLabel alloc] init];
        _descLabel.textColor = [UIColor grayColor];
        _descLabel.numberOfLines = 0;
        _descLabel.font = [UIFont systemFontOfSize:13 * WIDTH];
        [self.backView addSubview:_descLabel];
        [_descLabel release];
        
        
        
    }
    return self;
}

// 计算buyerBriefLabel宽度
+ (CGFloat)heightWithText:(NSString *)text {
    
    CGRect rect = [text boundingRectWithSize:CGSizeMake(375 * WIDTH - 20 * WIDTH, 1000 * HEIGHT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:13 * WIDTH]} context:nil];
    
    return rect.size.height;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.backView.frame = CGRectMake(0, 10 * HEIGHT, self.contentView.frame.size.width, self.contentView.frame.size.height - 20 * HEIGHT);
    _logoImageView.frame = CGRectMake(10 * WIDTH, 10 * HEIGHT, 40 * WIDTH, 40 * HEIGHT);
    _brandLabel.frame = CGRectMake(55 * WIDTH, 10 * HEIGHT, self.contentView.frame.size.width - 55 * WIDTH - 10 * WIDTH, 20 * HEIGHT);
    _siteImageView.frame = CGRectMake(55 * WIDTH, 30 * HEIGHT, 20 * WIDTH, 20 * HEIGHT);
    _siteLabel.frame = CGRectMake(80 * WIDTH, 30 * HEIGHT, 200 * WIDTH, 20 * HEIGHT);
    _lineView.frame = CGRectMake(10 * WIDTH, 70 * HEIGHT, self.contentView.frame.size.width - 20 * WIDTH, 1);
    CGFloat h = [[self class] heightWithText:_descLabel.text];
    _descLabel.frame = CGRectMake(10 * WIDTH, 90 * HEIGHT, self.contentView.frame.size.width - 20 * WIDTH, h * HEIGHT);
}




/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
